<!--
	作者：2575202388@qq.com
	时间：2019年8月6日17:11:48
	描述：家长推荐书籍管理搜索
-->
<template>
    <div style="width:100%;"> 
        <Tetable ref="tdtable" height="450" :columns="columns9" type="post" :paramiters="tj" :serverUrl="serverUrl"></Tetable>
        <edit ref="edit" v-on:reload="load()" :editparam="editparam"></edit>
        <setshzt ref="setshzt" v-on:setshzt="setshzt"></setshzt> 
        <looktm ref="looktm" :bid="bid" :recommendorid="recommendorid"></looktm>
		<setsfsj ref="setsfsj" v-on:setsfsj="setsfsj"></setsfsj> 
    </div> 
</template>
<script>
	import EditDelLook from "./EditDelLook";
	import edit from "./edit";
	import shzt from "./shzt";
	import setshzt from "./setshzt";
	import looktm from "./../sjgl/tm/manage";
	import setsfsj from "./setsfsj";
    export default {
    	name: "sjglss",
    	props: {
    		tj:{
    			type: Object
    		},	
    	},
        data () {
            return {
            	serverUrl:"/host/readbook/sjgl/Search_book.html?tjly=1",
                columns9: [
                    {
                        type: 'index',
                        width: 60,
                        title: '序号',
                        align: 'center'
                    },{
                        title: '上级分类名称',
                        key: 'PCLASSNAME',
                        align: 'center',
                    },{
                        title: '分类名称',
                        key: 'CLASSNAME',
                        align: 'center', 
                    },{
                        title: '书名',
                        key: 'BOOKNAME',
                        align: 'center', 
                    }, {
                        title: '作者',
                        key: 'AUTHOR',
                        align: 'center', 
                    }, {
                        title: '总页数',
                        key: 'TOTALPAGE',
                        align: 'center', 
                    },{
                        title: '最低读书量',
                        key: 'MINNUM',
                        align: 'center', 
                    },  {
                        title: '推荐年级',
                        key: 'NJ',
                        align: 'center', 
                    }, {
                        title: '推荐人所在班级',
                        key: 'NJBJ',
                        align: 'center', 
                    },{
                        title: '推荐人',
                        key: 'RECOMMENDOR',
                        align: 'center', 
                    },{
                        title: '上架/下架',
                        key: 'SFSJT',
                        align: 'center',  
						render: (h, params) => {
							return h("a", { 
						    	on: { 
						    		click: () => {
										if((this.user.permission && this.user.permission.indexOf("1")>-1) || this.user.uname=='admin'){
											this.bid=params.row.BID;
											this.$refs.setsfsj.modal0=true;
										}else{
											this.$Modal.error({
											    title: "提示",
											    content:'对不起，您没有此权限！'
											});
										}
										
						    		}
						    	} 
							},params.row.SFSJT)
						}
                    },{
                        title: '审核状态',
                        key: 'SHZT',
                        align: 'center', 
                        render: (h, params) => {
                        	return h(shzt, { 
                        		props: {
                                    sh: params.row.SH+"",
                                    shzt: params.row.SHZT,
                                },
	                        	on: { 
	                        		shenhe: () => {

										if((this.user.permission && this.user.permission.indexOf("1")>-1) || this.user.uname=='admin'){
											this.bid=params.row.BID;
											this.$refs.setshzt.modal0=true;
										}else{
											this.$Modal.error({
											    title: "提示",
											    content:'对不起，您没有此权限！'
											});
										}
	                        			
	                        		}
	                        	} 
                        	})
                        }
                    }, {
                        title: '操作',
                        key: 'action',
                        width: 200,
                        align: 'center',
                        render: (h, params) => {
                            return h(EditDelLook, {
                            	props: {
                                    sh: params.row.SH+"",
                                },
                            	on: {
                                    //修改书籍
                                    edit: () => {
                                    	const rows=params.row;
                                    	var bid="";
                                    	if(rows.BID){
                                    		bid=rows.BID;
                                    	}
                                    	var pid="";
                                    	if(rows.PID){
                                    		pid=rows.PID;
                                    	}
                                    	var classid="";
                                    	if(rows.CLASSID){
                                    		classid=rows.CLASSID;
                                    	}
                                    	var bookname="";
                                    	if(rows.BOOKNAME){
                                    		bookname=rows.BOOKNAME;
                                    	}
                                    	var totalpage=0;
                                    	if(rows.TOTALPAGE){
                                    		totalpage=rows.TOTALPAGE;
                                    	}
                                    	
                                    	var minnum=0;
                                    	if(rows.MINNUM){
                                    		minnum=rows.MINNUM;
                                    	}
                                    	
                                    	var fm="";
                                    	if(rows.FM){
                                    		fm=rows.FM;
                                    	}
                                    	
                                    	var nj=0;
                                    	if(rows.NJ){
                                    		nj=rows.NJ;
                                    	}
                                    		
                                    	var bj=0;
                                    	if(rows.BJ){
                                    		bj=rows.BJ;
                                    	}
                                    	
                                    	var author="";
                                    	if(rows.AUTHOR){
                                    		author=rows.AUTHOR;
                                    	}
                                    	
                                    	var reason="";
                                    	if(rows.REASON){
                                    		reason=rows.REASON;
                                    	}
                                    	
                                    	var bookjj="";
                                    	if(rows.BOOKJJ){
                                    		bookjj=rows.BOOKJJ;
                                    	}
                                    	
                                    	var authorjj="";
                                    	if(rows.AUTHORJJ){
                                    		authorjj=rows.AUTHORJJ;
                                    	}
                                    	
                                    	var bookxx="";
                                    	if(rows.BOOKXX){
                                    		bookxx=rows.BOOKXX;
                                    	}
                                    	
										var words="0";
										if(rows.WORDS){
											words=rows.WORDS;
										}

										var sh=0;
										if(rows.SH){
											sh=rows.SH;
										}
										
                                    	this.editparam={
                                    		bid:bid, //主键id
											pid:pid,//上级分类
											classid:classid,//分类id
											bookname:bookname, //书名
											totalpage:totalpage+"", //总页数
											minnum:minnum+"", //每天最低读书量
											fm:fm, //封面
											nj:nj+"", //推荐阅读年级
											bj:bj+"", //推荐阅读班级
											author:author, //作者
											reason:reason, //推荐理由
											bookjj:bookjj, //简介
											authorjj:authorjj,//作者简介
											bookxx:bookxx, //书籍基本信息
											words:words+"",//书籍总字数
											sh:sh+""
                                    	}
                                        this.$refs.edit.openmodal();
                                    },
                                    //删除书籍
                                    remove: () =>{
										const rows=params.row;
										if((this.user.permission && this.user.permission.indexOf("1")>-1) || this.user.uname=='admin' || rows.RECOMMENDORID==this.user.usid){
											this.remove(rows.BID)
										}else{
											this.$Modal.error({
											    title: "提示",
											    content:'对不起，您没有此权限！'
											});
										}
                                    },
                                    
                                  	//查看题目
                                    look: () =>{
                                    	this.bid=params.row.BID;
										this.recommendorid=params.row.RECOMMENDORID;
						           		this.$refs.looktm.modal0=true;
						           	},	 
                                    
                                }
                            });
                        }
                    }
                ],
                editparam:{},
                bid:'',
				recommendorid:'',
            }
        },
        computed: {
			user: function() {
				return this.$store.state.app.user;
			}
		},
		methods: {
			//删除书籍
			remove:function(bid){
                this.$Modal.confirm({
                    title: '警告',
                    content: '请确定是否删除！！！',
                    onOk: () => {
                    	//执行删除代码
                    	this.$http.get("/host/readbook/sjgl/del_book.html?bid="+bid)
						.then(datas => {
							if(datas.result){
								//删除成功 刷新页面
								this.$Message.info('删除成功');
								this.$refs.tdtable.load();
							}else{
								//删除成功 刷新页面
								this.$Message.info(datas.msg);
								this.$refs.tdtable.load();
							}
							
						});
                    }
                });
			},
			
			
			load(){
				this.$refs.tdtable.load();
			},


			setshzt(sh){
				const params={
					sh:sh,
					bid:this.bid
				};
				this.$http.post("/host/readbook/sjgl/setshzt.html",params)
				.then(result => {
					this.$Message.info('审核成功');
					this.$refs.setshzt.modal0=false;
					this.load();
				});
			},
			
			setsfsj(sfsj){
				const params={
					sfsj:sfsj,
					bid:this.bid
				};
				this.$http.post("/host/readbook/sjgl/booksetsfsj.html",params)
				.then(result => {
					this.$Message.info('操作成功');
					this.$refs.setsfsj.modal0=false;
					this.load();
				});
			},
	    },
		mounted() {
		},
		watch:{
		},
		components: {
			EditDelLook,
			edit,
			shzt,
			setshzt,
			looktm,
			setsfsj
		}
    }
</script>


<style scoped="scoped">
	
	.ivu-table-wrapper {
		border:none;
	}
	
	.toolstipdiv{
		width: '100%';
		overflow: 'hidden';
		textOverflow: 'ellipsis';
		whiteSpace: 'normal';
		wordBreak: 'break-all';
		color:'#fff';
		text-align: center;
	}
	.toolstipdiv:hover{
		background:rgb(63, 193, 201);
	}
	
	.ivu-tooltip-rel label:hover{
		color:#0023FB;
	}
	
	.tablediv{
		height: '40px';
		overflow:'hidden';
		line-height: '40px';
	}
</style>



